<template>
  <div>
    <div class="top">
      <van-search v-model="value" placeholder="请输入搜索关键词" show-action>
        <template #left>
          <van-icon name="arrow-left" @click="this.$router.back()" />
        </template>
        <template #label
          ><span @click="$router.push('/city')"
            >{{ localCity.label }}▼</span
          ></template
        >
        <template #action><van-icon name="send-gift" size="30" /></template>
      </van-search>
    </div>
    <van-dropdown-menu>
      <van-dropdown-item v-model="value1" title="区域">
        <van-picker :columns="columns"> </van-picker>
      </van-dropdown-item>
      <van-dropdown-item v-model="value2" title="方式">
        <van-picker :columns="sentType" />
      </van-dropdown-item>
      <van-dropdown-item v-model="value3" title="租金">
        <van-picker :columns="loadMoney" />
      </van-dropdown-item>
      <van-dropdown-item v-model="value4" title="筛选" @click="show = true">
      </van-dropdown-item>
      <van-overlay :show="show">
        <van-popup v-model="show">
          <div class="item-info">
            <div class="title"></div>
            <van-tag plain type="primary">标签</van-tag>
          </div>
          <div class="cancel">
            <van-button plain type="primary" class="left">取消 </van-button>
            <van-button type="primary" class="right">确定</van-button>
          </div>
        </van-popup>
      </van-overlay>
    </van-dropdown-menu>
  </div>
</template>

<script>
import { getLocalCity } from '@/utils/storage'
import { getGroups } from '@/api/index'
import { getInfo } from '@/api/findHouse'
export default {
  name: 'findhouse-page',
  components: {},
  props: {},
  data() {
    return {
      show: true,
      value: '',
      localCity: [],
      value1: 0,
      value2: 'a',
      value3: '',
      value4: '',
      sentType: [],
      loadMoney: [],
      columns: [
        {
          text: '区域',
          children: []
        },
        {
          text: '地铁',
          children: []
        }
      ]
    }
  },
  computed: {},
  watch: {},
  async created() {
    const res = await getGroups(this.localCity.value)
    this.contentList = [...res.data.body]
    this.localCity = getLocalCity()
    const res2 = await getInfo({ id: this.localCity.value })
    const list1 = res2.data.body
    list1.area.children.forEach((item) =>
      this.columns[0].children.push(item.label)
    )
    list1.subway.children.forEach((item) =>
      this.columns[1].children.push(item.label)
    )
    list1.rentType.forEach((item) => this.sentType.push(item.label))
    list1.price.forEach((item) => this.loadMoney.push(item.label))
    console.log(list1)
  },
  methods: {
    showPopup() {
      this.show = true
    }
  }
}
</script>

<style scoped lang="less">
.top {
  background-color: #21b97a;
  height: 50px;
  padding: 0 0 15px 0;
  ::v-deep .van-icon-arrow-left {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    font-size: 24px;
    color: #fff;
  }
  .van-icon-send-gift {
    margin-top: 10px;
  }
}
.van-overlay {
  z-index: 999;
  display: flex;
  width: 100%;
  height: 100%;
  ::v-deep .van-popup {
    margin-left: 80px;
    width: 295px;
    height: 100%;
    background-color: #fff;
    padding-bottom: 50px;
    .item-info{
      padding: 10px;
      .van-tag{
        width: 70px;
        height: 32px;
        line-height: 32px;
        text-align: center;
      }
    }
    .cancel {
      display: flex;
      width: 295px;
      height: 44px;
      position: fixed;
      bottom: 0;
      .left {
        flex: 3;
      }
      .right {
        text-align: center;
        flex: 12;
      }
    }
  }
}
</style>
